package com.twu.biblioteca.user;

import java.util.HashMap;

public class LibraryUserAuthenticator {
    private final HashMap<String, String> logins;

    public LibraryUserAuthenticator(HashMap<String, String> logins)
    {
        this.logins = logins;
    }

    public User authenticateUser(User user) {
        String password = logins.get(user.getUserId());
        if(password == null || password.isEmpty())
        {
           return user;
        }
        if(password.equals(user.getPassword()))
        {
            user.logInUser();
        }
        return user;
    }
}
